<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="js/jquery/jquery-1.7.1.js"></script>
    <link href="css/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="css/common_style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="js/authority/commonAll.js"></script>
    <script type="text/javascript" src="js/fancybox/jquery.fancybox-1.3.4.js"></script>
    <script type="text/javascript" src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
    <link rel="stylesheet" type="text/css" href="css/jquery.fancybox-1.3.4.css" media="screen"></link>
    <script type="text/javascript" src="js/artDialog/artDialog.js?skin=default"></script>
    <title>易居后台管理</title>
    <script type="text/javascript">
        $(document).ready(function(){
            /** 新增   **/
            $("#addBtn").fancybox({
                'href'  : 'sys_insertnews',
                'width' : 733,
                'height' : 530,
                'type' : 'iframe',
                'hideOnOverlayClick' : false,
                'showCloseButton' : false,
                'onClosed' : function() {
                    window.location.href = 'sys_news';
                }
            });

            /** 取消 **/

            $("#cancelbutton").click(function() {
                /**  关闭弹出iframe  **/
                window.parent.$.fancybox.close();
            });
            /**编辑   **/
            $("a.edit").fancybox({
                'width' : 733,
                'height' : 530,
                'type' : 'iframe',
                'hideOnOverlayClick' : false,
                'showCloseButton' : false,
                'onClosed' : function() {
                    window.location.href = 'sys_news';
                }
            });
        });
        
        /** 首页尾页跳转 **/
        function jumpPage(page){
            var form = document.getElementById("submitForm");
            if (page != 1) {
                document.getElementById("submitForm").action='/sys_news?page=' + '[[${pageDTO.page.getPages()}]]';
            }
            else{
                document.getElementById("submitForm").action='/sys_news?page=' + 1;
            }
            form.submit();
        }
        /** 下一页 **/
        function nextPage() {
            var form = document.getElementById("submitForm");
            document.getElementById("submitForm").action='/sys_news?page=' + '[[${pageDTO.page.getCurrent()+1}]]';
            form.submit();
        }
        /** 首页尾页跳转 **/
        function prePage() {
            var form = document.getElementById("submitForm");
            document.getElementById("submitForm").action='/sys_news?page=' + '[[${pageDTO.page.getCurrent()-1}]]';
            form.submit();
        }

    </script>
    <style type="text/css">
        .alt td{ background:black !important;}
        li{
            text-decoration: none;  /*去掉前面的圆点*/
            list-style: none;
            float: left;
        }
        .content_class{
            white-space:nowrap;/*文本不会换行，文本会在在同一行上继续，直到遇到 <br> 标签为止。*/
            overflow:hidden;/*隐藏多余的内容*/
            text-overflow:ellipsis;/*显示省略符号来代表被修剪的文本 for IE*/
            -moz-text-overflow: ellipsis; /* for Firefox,mozilla */
        }
    </style>
</head>
<body>
<form id="submitForm" name="submitForm" action="/sys_news" th:action="@{/sys_news}" method="post">
    <input type="hidden" name="allIDCheck" value="" id="allIDCheck"/>
    <input type="hidden" name="fangyuanEntity.fyXqName" value="" id="fyXqName"/>
    <div id="container">
        <div class="ui_content">
            <div class="ui_text_indent">
                <div id="box_border">
                    <div id="box_top">
                        共有新闻&nbsp;&nbsp;</b><span th:text="${pageDTO.page.getTotal()}">1000</span><b>条
                    </div>
                    <div id="box_center">
                        标题
                            <input type="text" style="width: 300px" class="form-control" id="search" placeholder="请输入你要查找的标题"
                                   name="title" th:value="${select.title}">
                            <!--<input type="hidden" id="order" name="order" th:value="${select.order}">-->
                        新闻类型
                        <select name="type" id="type" class="ui_select01">
                            <option value="">--请选择--</option>
                            <option value="情感" selected="selected" th:if="${select.typeContain('情感')}">情感</option>
                            <option value="情感" th:unless="${select.typeContain('情感')}">情感</option>
                            <option value="房价" selected="selected" th:if="${select.typeContain('房价')}">房价</option>
                            <option value="房价" th:unless="${select.typeContain('房价')}">房价</option>
                        </select>
                        审核状态
                        <select name="status" id="status" class="ui_select01">
                            <option value="">--请选择--</option>
                            <option value="0" selected="selected" th:if="${select.statusContain('0')}">待审核</option>
                            <option value="0" th:unless="${select.statusContain('0')}">待审核</option>
                            <option value="1" selected="selected" th:if="${select.statusContain('1')}">通过</option>
                            <option value="1" th:unless="${select.statusContain('1')}">通过</option>
                        </select>
                    </div>
                    <div id="box_bottom">
                        <input type="submit" value="查询" class="ui_input_btn01"/>
                        <input type="button" value="新增" class="ui_input_btn01" id="addBtn" />
                        <input type="button" value="删除" class="ui_input_btn01" onclick="batchDel();" />
                    </div>
                </div>
            </div>
        </div>
        <div class="ui_content">
            <div class="ui_tb">
                <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0" style="table-layout: fixed">
                    <tr>
                        <th>标题</th>
                        <th>内容</th>
                        <th>类型</th>
                        <th>创建时间</th>
                        <th>访问量</th>
                        <th>审核状态</th>
                        <th>操作</th>
                    </tr>
                    <div th:each="news : ${pageDTO.result}" class="row">
                        <tr>
                            <td style="color: black; text-decoration: none; font-weight: bold" href="#4"
                                th:href="@{'/news_detail?newsId='+${news.newsId}}"
                                th:text="${news.title}">标题</td>
                            <td class="content_class" th:text="${news.content}">内容</td>
                            <td th:text="${news.type}">类型</td>
                            <td th:text="${news.createTime}">2018-0809<</td>
                            <td th:text="${news.visits}">访问量</td>
                            <td th:text="通过" th:if="${news.status}"></td>
                            <td th:text="待审核" th:unless="${news.status}"></td>
                            <td>
                                <a th:if="${news.status}" th:href="@{'/status_sysnews?newsId=' + ${news.newsId} + '&status='+${news.status}}"
                                   class="btn btn-default">重新审核</a>
                                <a th:unless="${news.status}" th:href="@{'/status_sysnews?newsId=' + ${news.newsId} + '&status='+${news.status}}"
                                   class="btn btn-default">通过审核</a>
                                <!--<a href="javascript:del('14458579642011');" th:href="@{'/sys_deletenews?newsId=' + ${news.newsId}}">删除</a>-->
                                <a  class="btn btn-default" onclick="dele(this)" th:value="${news.newsId}">删除</a>
                            </td>
                        </tr>
                    </div>
                </table>
            </div>
        </div>
    </div>
</form>
<script>
    function dele(sender) {
        var msg=confirm("确定删除？");    //弹出一个窗口，询问客户信息，然后返回boolean值
        if(msg == true){
            $(document).ready(function(){
                $.ajax({
                    type:"GET",
                    url:"/sys_deletenews?newsId="+$(sender).attr("value"),
                    async:false,
                    success:function (data) {
                        alert("删除成功");
                        location.reload();
                    },
                    error:function (jqXHR) {
                        alert("删除失败");
                    }
                });
            });
        }
        else  {
        }
    }
</script>
<!-- 分页条 -->
<div class="container">
    <div class="row">
        <nav style="text-align: left" aria-label="Page navigation">
            <ul class="pagination">
                <li ><a style="color: black" th:text="' 第 '+${pageDTO.page.getCurrent()}+' 页/共 '+${pageDTO.page.getPages()}+' 页 '"/></li>
                <li>
                    <button onclick="jumpPage(1)">首页</button>
                </li>
                <li th:if="${pageDTO.page.hasPrevious()}">
                    <button aria-label="Previous" onclick="prePage()">上一页</button>
                </li>
                <li th:if="${pageDTO.page.hasNext()}">
                    <button aria-label="Next" onclick="nextPage()">下一页</button>
                </li>
                <li>
                    <button onclick="jumpPage(0)">尾页</button>
                </li>
                <li><input type="button" id="cancelbutton"   value="关闭" /></li>
            </ul>
        </nav>
    </div>
</div>
</body>
</html>
